#include "test.h"
#include "ui_test.h"
#include "customscroll.h"
#include <QDebug>

test::test(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::test)
{
    ui->setupUi(this);
    student_model = new QStandardItemModel();
    student_model->setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("姓名")));
    student_model->setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("学号")));
    student_model->setHorizontalHeaderItem(2, new QStandardItem(QObject::tr("性别")));
    student_model->setHorizontalHeaderItem(3, new QStandardItem(QObject::tr("年龄")));
    student_model->setHorizontalHeaderItem(4, new QStandardItem(QObject::tr("学院")));
    //利用setModel()方法将数据模型与QTableView绑定
    for(int i = 0;i < 50;i ++)
    {
        student_model->setItem(i, 0, new QStandardItem("江涛"));
        student_model->setItem(i, 1, new QStandardItem("20210124"));
        student_model->setItem(i, 2, new QStandardItem("男"));
        student_model->setItem(i, 3, new QStandardItem("18"));
        student_model->setItem(i, 4, new QStandardItem("电力学院"));
    }
    ui->tableView->setModel(student_model);
    buff = new CustomScroll(ui->tableView,this);;
}

test::~test()
{
    delete ui;
}
